package com.xiaobai.stream_practice.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * @author wangtw
 * @ClassName Author
 * @description: 作家实体类
 * @date 2024/2/1316:03
 */
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Data
public class Author implements Comparable<Author> {

    private String realName;

    private Integer age;

    private String sex;

    private String profile;

    private Double salary;

    private List<Book> bookList;

    @Override
    public String toString() {
        return "Author{" +
                "realName='" + realName + '\'' +
                ", age=" + age +
                ", sex='" + sex + '\'' +
                ", profile='" + profile + '\'' +
                ", salary=" + salary +
                ", bookList=" + bookList +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Author author = (Author) o;
        return Objects.equals(getRealName(), author.getRealName()) && Objects.equals(getAge(), author.getAge()) && Objects.equals(getSex(), author.getSex()) && Objects.equals(getProfile(), author.getProfile()) && Objects.equals(getSalary(), author.getSalary()) && Objects.equals(getBookList(), author.getBookList());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getRealName(), getAge(), getSex(), getProfile(), getSalary(), getBookList());
    }

    @Override
    public int compareTo(Author author) {
        return Integer.compare(this.getAge(), author.getAge());
    }
}
